import React,{ Component } from "react";
import { SafeAreaView, Text, View, Platform } from 'react-native';
import RootStack from './Navigation/RootStack';
import { Provider } from 'react-redux'
import store from './store';
import Constant from './utils/Constant'//全局变量

const isIos = Platform.OS == 'ios';

export default class Root extends Component {
    constructor(props) {
        super(props);
        Constant.apiDomain = this.props.apiDomain
        Constant.webDomain = this.props.webDomain
        Constant.imApiAddr = this.props.imApiAddr
        Constant.imWsAddr = this.props.imWsAddr
        Constant.imgDomain = 'https://img.shuaiche.com/'

        Constant.apiType = this.props.apiType
        
        Constant.sessionId = this.props.sessionId
        Constant.userInfo = this.props.userInfo ? JSON.parse(this.props.userInfo):{}

        BarHeight = isIos ? this.props.statusBarHeight : this.props.statusBarHeight;
        isIPhoneX = isIos ? (BarHeight > 20 ? 1 : 0) : 0;
        bottomHeight = isIos ? (BarHeight > 20 ? 34 : 0) : 15

        Constant.statusBarHeight = BarHeight;
        Constant.navigationBarHeight = isIos ? 44:49
        Constant.bottomHeight = bottomHeight;
        Constant.isIPhoneX = isIPhoneX;

        Constant.release =  this.props.release ? this.props.release : false;

        console.log('Constant = ',Constant)
    }
    render() {
        return (
            <Provider store={store}>
                <RootStack />
            </Provider>
            
        );
    }
};